Skip to content

fix(llm): stop classifying Bedrock throttling as context overflow - #39623

Open
skogaby wants to merge 2 commits into
anomalyco:devfrom
skogaby:bedrock-throttle-overflow
Open

fix(llm): stop classifying Bedrock throttling as context overflow#39623
skogaby wants to merge 2 commits into
anomalyco:devfrom
skogaby:bedrock-throttle-overflow

Conversation

@skogaby

@skogaby skogaby commented Jul 30, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #39620

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Bedrock's ThrottlingException message "Too many tokens, please wait before trying again." matched the /too many tokens/i overflow pattern while the throttling exclusion only matched a literal "throttling error:" prefix the AI SDK never emits. The 429 was converted into a ContextOverflowError, which skipped retry and triggered a spurious auto-compaction instead of backing off.

Broaden the exclusion list to match throttle vocabulary and transient retry language anywhere in the message, and gate parseAPICallError so a 429 status is never classified as context overflow.

How did you verify your code works?

Built a local copy of opencode and ran it on an account experiencing heavy throttling on AWS Bedrock. Normally this would trigger an auto-compaction almost immediately, but this time I saw proper backoff-retries.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

skogaby added 2 commits July 30, 2026 00:35
Bedrock's ThrottlingException message "Too many tokens, please wait
before trying again." matched the /too many tokens/i overflow pattern
while the throttling exclusion only matched a literal "throttling
error:" prefix the AI SDK never emits. The 429 was converted into a
ContextOverflowError, which skipped retry and triggered a spurious
auto-compaction instead of backing off.

Broaden the exclusion list to match throttle vocabulary and transient
retry language anywhere in the message, and gate parseAPICallError so
a 429 status is never classified as context overflow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AWS Bedrock 429 "Too many tokens, please wait before trying again" triggers auto-compaction instead of retry

1 participant